View Statement is the essentially subset of table which are put away sensibly in a database means a view is a virtual table in the database whose substance are characterized by a query. Views Help in Providing Security , As we can limit number of segments/fields you can access from
Suppose you are working on a project and there are lot of events. In the event that you have any sql query and you don’t need to store query in any content file or PHP, you make a view Statement and store in mysql.
Create View Syntax
Suppose i have a table in my database named “users”. So now i will create a view for users table.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// this is view statement to select all users table data CREATE VIEW get_all_users AS SELECT * FROM `users` // we can also create view with where condition CREATE VIEW get_user_details AS SELECT * FROM `users` WHERE `user_id` =1 // we can also create view with order by and limit conditions CREATE VIEW get_users AS SELECT * FROM `users` ORDER BY (ASC OR DESC) LIMIT 0,10 |
They are comparable to query with the exception of the way that the yield segments can be additionally utilized in queries. So its a sort of settled query thought.
The Purpose of Views Statement are To decrease code intricacy and take the advantage of Code Re-ease of use .
Basically If we are having complex questions with joins and so on you can make and put in view and utilize that view where need of reusing it.
Keep in mind views Statement are not for execution reason these are for keeping up code manageable.
To the database user, the view seems simply like a genuine table, with an arrangement of named sections and columns of information.
SQL makes the fantasy of the view by giving the view a name like a table name and putting away the meaning of the view in the database.
View Statements are utilized for security reason in databases,views confines the user from viewing certain section and lines implies by utilizing view we can apply the limitation on getting to the specific lines and segments for explicit user.
Views show just those information which are referenced in the query, so it indicates just information which is returned by the query that is characterized at the season of production of the View.
[yotuwp type=”videos” id=”CMEAI7OAtX4″ column=”1″ player=”mode=large&autonext=0&rel=0&cc_load_policy=0&iv_load_policy=3″]
Pradeep Maurya is the Professional Web Developer & Designer and the Founder of “Tutorials website”. He lives in Delhi and loves to be a self-dependent person. As an owner, he is trying his best to improve this platform day by day. His passion, dedication and quick decision making ability to stand apart from others. He’s an avid blogger and writes on the publications like Dzone, e27.co